package com.lincoln.server.sms;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@RestController
@EnableDiscoveryClient
public class SmsServerApplication {

    @Value("${server.port}")
    private int port;

    public static void main(String[] args) {
        SpringApplication.run(SmsServerApplication.class, args);
    }

    @GetMapping("/sendSms")
    public String sendSms(String content) throws UnknownHostException {
        return "[本条短信由服务器" + InetAddress.getLocalHost().getHostAddress() + ":" + port + "发送,内容为:{" + content + "}]";
    }
}
